<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public:header2" />
    <script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Home/js/jquery.cookies.2.2.0.js"></script>
</head>
<body class="blackbg">
    <div id="container" class="logbg">
        <div class="log_title">
            <span class="back"><a href="javascript:history.go(-1)"></a></span>
            {:L('修改登录密码')}
        </div>
        <div class="logbot">
            <form>
                <input type="password" placeholder="{:L('原登录密码')}" class="logipt" id="oldpassword">
                <input type="password" placeholder="{:L('新登录密码')}" class="logipt" id="newpassword">
                <p style="font-size:14px;line-height:24px;color:#ff8800;padding-left:10px;">{:L('警告：登录密码不要与交易密码或者其他网站密码一致，由此产生的账号被盗，本站概不负责。')}</p>
                <input type="password" placeholder="{:L('重复新密码')}" class="logipt" id="repassword">

                <div class="yzmbox">
                    <input type="text" placeholder="{:L('验证码')}" class="logipt yzmipt"  id="mobile_verify" >
                	<input type="button" value="{:L('获取验证码')}" class="phonebut" id="regBtn"  value="{:L('获取验证码')}" onclick="SendCode()" style="margin-top:15px;background:#ff9900;color:#fff;">
                	<p id="repassword-msg" data-explain="{:L('重复输入密码，两次需要一致')}<em></em>" style="font-size:14px;line-height:24px;color:#ff8800;padding-left:10px;">{:L('接收短信的手机')}{$mobile}<em></em></p>
                </div>
                <input type="button" class="logbut" value="{:L('保存')}" onclick="Update()">
            </form>
        </div>
    </div>
<script>
    function SendCode() {
        layer.load(0, {shade: [0.5,'#8F8F8F']});
        $('#regBtn').attr("disabled", "disabled");
        $.post("{:U('Verify/pass')}", {}, function (data) {
          layer.closeAll();
          if (data.status == 1) {
            layer.msg(data.info, {
              icon: 1
            });
            var obj = $('#regBtn');
            var wait = 120;
            var interval = setInterval(function () {
              obj.css('backgroundColor', '#999B9C');
              obj.val(wait + '{:L('秒再次发送')}');
              wait--;
              if (wait < 0) {
                $('#regBtn').removeAttr("disabled");
                clearInterval(interval);
                obj.val('{:L('获取验证码')}');
                obj.css('backgroundColor', '#ff9900');
              }
              ;
            }, 1000);
          } else {
            $('#regBtn').removeAttr("disabled");
            layer.msg(data.info, {
              icon: 2
            });
          }
        }, "json");
      }

	function Update() {
		var mobile_verify = $("#mobile_verify").val();
		if (mobile_verify == "" || mobile_verify == null) {
			layer.tips('{:L('请输入短信验证码')}', '#mobile_verify', {tips: 3});
			return false;
		}
		$.post("{:U('User/uppassword')}", {
			oldpassword: $('#oldpassword').val(),
			newpassword: $('#newpassword').val(),
			mobile_verify: $('#mobile_verify').val(),
			repassword: $('#repassword').val()
		}, function (data) {
			if (data.status == 1) {
				layer.msg(data.info, {icon: 1});
				setTimeout("remainTime()",3000);
			} else {
				layer.msg(data.info, {icon: 2});
				if (data.url) {
					window.location = data.url;
				}
			}
		}, "json");
	}
	
	function remainTime(){ 
		window.location = "{:U('User/index')}";
	}
</script>
</body>
</html>